package cn.sinjinsong.eshop.common.domain.entity.user;

import cn.sinjinsong.eshop.common.enumeration.user.UserStatus;
import cn.sinjinsong.eshop.common.properties.DateTimeProperties;
import cn.sinjinsong.eshop.common.validator.Past;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Email;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserDO implements Serializable {
    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column user.id
     *
     * @mbggenerated
     */
    private Long id;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column user.username
     *
     * @mbggenerated
     */
    @NotNull
    private String username;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column user.password
     *
     * @mbggenerated
     */
    private String password;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column user.nickname
     *
     * @mbggenerated
     */
    @NotNull
    private String nickname;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column user.realName
     *
     * @mbggenerated
     */

    private String realName;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column user.sex
     *
     * @mbggenerated
     */

    private String sex;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column user.birthday
     *
     * @mbggenerated
     */
    @Past
    @JsonFormat(pattern = DateTimeProperties.LOCAL_DATE_PATTERN)
    private LocalDate birthday;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column user.reg_time
     *
     * @mbggenerated
     */
    @JsonFormat(pattern = DateTimeProperties.LOCAL_DATE_TIME_PATTERN)
    private LocalDateTime regTime;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column user.email
     *
     * @mbggenerated
     */
    @NotNull
    @Email
    private String email;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column user.phone
     *
     * @mbggenerated
     */
    @NotNull
    @Pattern(regexp = "[0-9]+")
    private String phone;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column user.roles
     *
     * @mbggenerated
     */
    private List<RoleDO> roles;

    private UserStatus userStatus;
    private String avatar;
    public UserDO(Long id) {
        this.id = id;
    }

}